package com.ricervcvcer.goods.controller;


import com.ricervcvcer.common.util.ResultEntity;
import com.ricervcvcer.goods.entity.TbSpecParam;
import com.ricervcvcer.goods.mapper.TbSpecParamMapper;
import com.ricervcvcer.goods.service.ITbSpecParamService;
import com.ricervcvcer.goods.vo.SpecParamVO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 规格参数组下的参数名 前端控制器
 * </p>
 *
 * @author moge
 * @since 2022-01-06
 */
@RestController
@RequestMapping("/tb-spec-param")
public class TbSpecParamController {
    @Autowired
    ITbSpecParamService specParamService;
    @Autowired
    TbSpecParamMapper specParamMapper;
    @ApiOperation("分类id查询规格信息")
    @RequestMapping("cid/{cid}")
    public ResultEntity getByCid(@ApiParam("分类id") @PathVariable Long cid){
        List<SpecParamVO> list = specParamService.selByCid(cid);
        return ResultEntity.successWithData(list);
    }

    @ApiOperation("id查询规格信息")
    @RequestMapping("id/{id}")
    public ResultEntity<TbSpecParam> getByid(@ApiParam("分类id") @PathVariable("id") Long id){
        TbSpecParam param = specParamMapper.selectById(id);
        return ResultEntity.successWithData(param);
    }
}
